import { getPurchaseListApi } from '@/api/workflow/purchase'

// 获取采购列表hooks
export default function useGetPurchaseList() {
  const purchaseOptions = ref([])
  const purchaseLoading = ref(false)
  const { userInfo } = getUserInfo()

  const fetchGetPurchaseList = async (isInStore = false) => {
    purchaseLoading.value = true
    const res = await getPurchaseListApi({
      isInStore,
      orgId: userInfo.value.orgId
    })
    if (res.code === '0000') {
      purchaseOptions.value = res.data
    }
    purchaseLoading.value = false
  }

  fetchGetPurchaseList()

  return {
    fetchGetPurchaseList,
    purchaseOptions,
    purchaseLoading
  }
}
